package com.example.bijiabao.servicesImpl;

import com.example.bijiabao.entity.book;
import com.example.bijiabao.services.indexServices;
import com.example.bijiabao.mapper.indexMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public  class indexServicesImpl implements indexServices {
    @Autowired
    private indexMapper indexMapper;


//    @Override
//    public PageInfo<book> findAllbook(Integer num) {
//        PageHelper.startPage(num,12);
//        List<book> list = indexMapper.findAllbook();
//        PageInfo<book> pageInfo = new PageInfo<>(list);
//        return pageInfo;
//    }
//
//    @Override
//    public PageInfo<book> findAllbookbycomnum(Integer num) {
//        PageHelper.startPage(num,12);
//        List<book> list = indexMapper.findAllbookbycomnum();
//        PageInfo<book> pageInfo = new PageInfo<>(list);
//        return pageInfo;
//    }

    //热销榜
    @Override
    public List<book> findhotbook() {
        List<book> list = indexMapper.findhotbook();
        return list;
    }

    //首页左边书籍
    //热销榜
    @Override
    public List<book> findAllbookbycomnum() {
        List<book> list = indexMapper.findAllbookbycomnum();
        return list;
    }

    //首页左边书籍带分页
    public PageInfo<book> findAllbook(Integer num) {
       PageHelper.startPage(num,12);
      List<book> list = indexMapper.findAllbook();
        PageInfo<book> pageInfo = new PageInfo<>(list);
       return pageInfo; }
}
